<?php
/*
   Copyright 2012 BiSe Trojanov

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
 require_once('config.php');


?><!doctype html><html>
<head>
 <?php include('./include/header.inc'); ?>
 <title><?php echo $LANGS['index']['title'].' / '.$sad_domain; ?></title>
 <script>
  $(document).ready(function(){
   if (navigator.userAgent.search('Opera')>-1 || navigator.userAgent.search('Firefox')>-1 || navigator.userAgent.search('Chrome')>-1){$('#badbrowser').hide();}
  });
 </script>
</head>
<body>
<?php include('./include/toolbar.inc'); ?>
<div class="infobox" id="badbrowser"><?php echo $LANGS['index']['badbrowser'] ?><table class="noborder" style="width: 100%;"><tr><td></td>
<td style="vertical-align: middle; text-align: center;"><a href="http://google.com/chrome/" target="_blank"><img src="style/chrome.png"><br />Google Chrome</a></td><td></td>
<td style="vertical-align: middle; text-align: center;"><a href="http://mozilla-europe.org/" target="_blank"><img src="style/firefox.png"><br />Mozilla Firefox</a></td><td></td>
<td style="vertical-align: middle; text-align: center;"><a href="http://opera.com/" target="_blank"><img src="style/opera.png"><br />Opera</a></td><td></td>
</tr></table></div><script>


</script>

<table>
 <tr><td title="sad_version"><?php echo $LANGS['index']['l_version']; ?></td><td><a href="http://code.google.com/p/ascetcms/" target="_blank">AscetCMS/<b title="sad_version"><?php echo $sad_version;?></b></a></td><tr>
 <tr><td><?php echo $LANGS['index']['l_doc_root']; ?></td><td><?php echo $_SERVER['DOCUMENT_ROOT'];?></td><tr>
 <tr><td title="sad_root"><?php echo $LANGS['index']['l_cmsroot']; ?></td><td><?php echo $sad_root;?></td><tr>
 <tr><td title="sad_protocol"><?php echo $LANGS['index']['l_protocol']; ?></td><td><?php echo $sad_protocol;?></td><tr>
 <tr><td title="sad_domain"><?php echo $LANGS['index']['l_domain']; ?></td><td><?php echo $sad_domain;?></td><tr>
 <tr><td title="sad_baseurl"><?php echo $LANGS['index']['l_cmsurl']; ?></td><td><?php echo $sad_baseurl;?></td><tr>

</table>

<?php
 $a=array_flip(get_loaded_extensions());
 if (!isset($a['dom'])){     echo '<div class="infobox">'.$LANGS['index']['mn_dom'].'</div>';}
 if (!isset($a['libxml'])){  echo '<div class="infobox">'.$LANGS['index']['mn_libxml'].'</div>';}
 if (!isset($a['gd'])){      echo '<div class="infobox">'.$LANGS['index']['mn_gd'].'</div>';}
 if (!isset($a['iconv'])){   echo '<div class="infobox">'.$LANGS['index']['mn_iconv'].'</div>';}
 if (!isset($a['curl'])){    echo '<div class="infobox">'.$LANGS['index']['mn_curl'].'</div>';}
 if (!isset($a['mbstring'])){echo '<div class="infobox">'.$LANGS['index']['mn_mbstring'].'</div>';}
 
?><table>
 <tr><td>PHP Version</td><td title="<?php echo sad_php_version();?>"><?php echo phpversion();?></td></tr>
 <tr><td>OS</td><td><?php echo php_uname();?></td></tr>
 <tr><td title="php_sapi_name"><?php echo $LANGS['index']['l_handler']; ?></td><td><?php echo php_sapi_name();?></td></tr>

<?php
 echo '<tr><td title="post_max_size">'.$LANGS['index']['l_post_max'].'</td><td>'.drawsize(parsesize(ini_get('post_max_size')),'-.2').'</td></tr>';
 echo '<tr><td title="upload_max_filesize">'.$LANGS['index']['l_upload_max'].'</td><td>'.drawsize(parsesize(ini_get('upload_max_filesize')),'-.2').'</td></tr>';
 echo '<tr><td title="memory_limit">'.$LANGS['index']['l_memory_lim'].'</td><td>'.drawsize(parsesize(ini_get('memory_limit')),'-.2').'</td></tr>';
 if (function_exists('mb_internal_encoding')){
  echo '<tr><td title="mb_internal_encoding">'.$LANGS['index']['l_int_enc'].'</td><td>'.mb_internal_encoding().'</td></tr>';
 }
 echo '<tr><td title="display_errors">'.$LANGS['index']['l_disp_er'].'</td><td>';
 if (ini_get('display_errors')){echo 'Yes';}else{echo 'No';}
 echo '</td></tr>';
 /* echo '<tr><td title="suhosin.sql.bailout_on_error">Hide SQL-errors via Suhosin patch</td><td>';
 if (ini_get('suhosin.sql.bailout_on_error')){echo 'Yes';}else{echo 'No';}
 echo '</td></tr>'; */
 echo '</table>';

 if (function_exists('apache_get_modules')){
  $a=array_flip(apache_get_modules());
  if (!isset($a['mod_rewrite'])){echo '<div class="infobox">'.$LANGS['index']['ma_rewrite'].'</div>';}
 }
 
 if (iamd()){
  if ($_GET['action']=='error_type'){
   $t1=$_SESSION['error_type'] ^ ($_SESSION['error_type'] & $_GET['id']);
   if ((int)($_GET['value'])>0){$t1=$t1 | $_GET['id'];}
   $_SESSION['error_type']=$t1;
  }
  if ($_GET['action']=='error_disp'){
   $_SESSION['error_disp']=$_GET['value'];
  }
  
  $sad_tmp_ers=array(
   array('name'=>'E_ERROR'),
   array('name'=>'E_WARNING'),
   array('name'=>'E_PARSE'),
   array('name'=>'E_NOTICE'),
   array('name'=>'E_CORE_ERROR'),
   array('name'=>'E_CORE_WARNING'),
   array('name'=>'E_COMPILE_ERROR'),
   array('name'=>'E_COMPILE_WARNING'),
   array('name'=>'E_USER_ERROR'),
   array('name'=>'E_USER_WARNING'),
   array('name'=>'E_USER_NOTICE'),
   array('name'=>'E_STRICT'),
   array('name'=>'E_RECOVERABLE_ERROR')
  );
  if (sad_php_version()>=50400){$sad_tmp_ers[]=array('name'=>'E_DEPRECATED');}
  
  echo '<table>';$t2='';$t3='';
  echo '<tr><td></td><td><a href="?action=error_disp&value='.(1-$_SESSION['error_disp']).'" class="nicebutton" style="width:220px; padding:5px;';
  if ($_SESSION['error_disp']<1){echo 'color: #ccc;';}else{echo 'color: #ff3;font-weight: bold;';}
  echo '">display_errors</a></td><td>'.$LANGS['error_reporting']['display_error'].'</td></tr>';
  foreach ($sad_tmp_ers as $sad_tmp_er){
   $t1=(int)(($_SESSION['error_type'] & eval('return '.$sad_tmp_er['name'].';'))>0);
   echo '<tr><td>'.eval('return '.$sad_tmp_er['name'].';').'</td><td><a href="?action=error_type&value='.(1-$t1).
        '&id='.eval('return '.$sad_tmp_er['name'].';').'" class="nicebutton" style="width:220px; padding:5px;';
   if ($t1>0){$t2.=' | '.$sad_tmp_er['name'];}else{echo 'color: #ccc;';$t3.=' ^ '.$sad_tmp_er['name'];}
   echo '">'.$sad_tmp_er['name'].'</a></td><td>'.$LANGS['error_reporting'][$sad_tmp_er['name']].'</td></tr>';
  }
  echo '</table>';
  if (strlen($t2)-3>strlen($t3)+5){echo 'error_reporting(E_ALL'.$t3.');';}else{echo 'error_reporting('.substr($t2,3).');';}
 }
?>

</body></html>